package cc.magicjson.mall.product.interfaces.rest;

import cc.magicjson.mall.product.application.command.CreateProductCommand;
import cc.magicjson.mall.product.application.service.ProductApplicationService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

@RestController
@RequestMapping("/products")
public class ProductController {
	private final ProductApplicationService productApplicationService;

	public ProductController(ProductApplicationService productApplicationService) {
		this.productApplicationService = productApplicationService;
	}

	@PostMapping("create")
	public ResponseEntity<String> createProduct(@RequestBody CreateProductCommand command) {
		return ResponseEntity.ok(productApplicationService.createProduct(command));
	}


	@GetMapping("price/{productId}")
	public BigDecimal getProductPrice(@PathVariable("productId") String productId) {
		return productApplicationService.getProductPrice(productId);
	}

	// Other controller methods
}

	// TODO 其他控制器方法...
